<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%article_content}}".
 *
 * @property int $id 自增id
 * @property int $aid 文章id
 * @property string $content 文章详细内容
 *
 * @property Article $a
 */
class ArticleContent extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%article_content}}';
    }

    /**
     * {@inheritdoc}
     * @return ArticleContentQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new ArticleContentQuery(get_called_class());
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['aid'], 'integer'],
            [['content'], 'required'],
            [['content'], 'string'],
            [['aid'], 'exist', 'skipOnError' => true, 'targetClass' => Article::className(), 'targetAttribute' => ['aid' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id'      => '自增id',
            'aid'     => '文章id',
            'content' => '文章详细内容',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getA()
    {
        return $this->hasOne(Article::className(), ['id' => 'aid']);
    }
}
